package learn.up.java.core.reflect;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

public class TestReflect_Factory {

	public static void main(String[] args) {
		//调用非反射模式的创建实例的方法
		Fruit f=Reflect_Factory.newInstance("Apple");
		f.eat();
		//调用利用反射模式的工厂方法
		try {
			Properties p=Reflect_Factory.getProperties();
			Fruit f2=(Fruit)Reflect_Factory.getInstance(p.getProperty("Orange"));
			if(f2!=null){
				f2.eat();
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

}
